@echo off
echo ==========================================
echo 模块声明问题修复工具
echo ==========================================

cd %~dp0..

echo 正在检查模块声明问题...
npx eslint src/views/**/*.vue --quiet --max-warnings=0 --rule "import/no-unresolved: error" > module-errors.txt

echo 生成统计报告...
echo 模块声明问题报告 > module-report.txt
echo 生成时间: %date% %time% >> module-report.txt
echo ==========================================>> module-report.txt
echo. >> module-report.txt

type module-errors.txt | findstr /C:"Cannot find module" >> module-report.txt

echo. >> module-report.txt
echo ==========================================>> module-report.txt
echo 可能缺少的模块声明: >> module-report.txt
echo. >> module-report.txt

type module-errors.txt | findstr /C:"Cannot find module" | findstr /C:"@/api" > api-modules.txt
type module-errors.txt | findstr /C:"Cannot find module" | findstr /C:"@/utils" > utils-modules.txt

echo API模块声明问题: >> module-report.txt
type api-modules.txt >> module-report.txt
echo. >> module-report.txt

echo 工具模块声明问题: >> module-report.txt
type utils-modules.txt >> module-report.txt
echo. >> module-report.txt

echo ==========================================>> module-report.txt
echo 修复建议: >> module-report.txt
echo. >> module-report.txt
echo 1. 在src/types/global.d.ts中添加缺失的模块声明: >> module-report.txt
echo. >> module-report.txt
echo    declare module "@/api/模块路径" { >> module-report.txt
echo      import { AxiosPromise } from "axios"; >> module-report.txt
echo      export function functionName(params: ParamType): AxiosPromise<ResponseType>; >> module-report.txt
echo    } >> module-report.txt
echo. >> module-report.txt
echo 2. 运行rebuild-types.bat重建类型缓存 >> module-report.txt
echo. >> module-report.txt

echo 清理临时文件...
del api-modules.txt
del utils-modules.txt

echo 模块声明问题报告已生成: module-report.txt
echo ========================================== 